﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;

namespace Gemciler_Uretim.CekListesi
{
    public partial class KayıtSecimEkrani : DevExpress.XtraEditors.XtraForm
    {
        public KayıtSecimEkrani()
        {
            InitializeComponent();
        }
        SqlConnecitonClass sqlbaglanti = new SqlConnecitonClass();
        public string secilen_kod, secilen_ad, secilen_kayitno,secilen_tel,secilen_plaka,sqlsorgu,secim_tipi;
        private void KayıtSecimEkrani_Load(object sender, EventArgs e)
        {
            gridControl1.DataSource = null;
            gridView1.Columns.Clear();

            gridControl1.DataSource = sqlbaglanti.ShowTable(""+sqlsorgu+"", CommandType.Text);
            this.gridControl1.TabIndex = 0;
            this.gridView1.OptionsBehavior.AllowIncrementalSearch = true;
            this.gridView1.OptionsView.ShowAutoFilterRow = true;
            this.gridView1.OptionsView.ShowGroupPanel = false; // gruplama alanı
            this.gridView1.OptionsBehavior.Editable = false;
            this.gridView1.OptionsBehavior.ReadOnly = false;
            this.gridView1.OptionsView.ShowFooter = true;
            gridView1.OptionsView.ColumnAutoWidth = false;
            this.gridView1.Appearance.HeaderPanel.TextOptions.WordWrap = DevExpress.Utils.WordWrap.Wrap;
            this.gridView1.ColumnPanelRowHeight = 55;

            gridView1.OptionsView.HeaderFilterButtonShowMode = FilterButtonShowMode.Button;
            gridView1.BestFitColumns();
        }

        private void gridView1_DoubleClick(object sender, EventArgs e)
        {
            try
            {
                if (secim_tipi == "")
                {

                    int index1 = gridView1.FocusedRowHandle;
                    secilen_kod = Convert.ToString(gridView1.GetRowCellValue(index1, "KOD").ToString());
                    secilen_ad = Convert.ToString(gridView1.GetRowCellValue(index1, "ADI").ToString());
                   
                    Close();
                }
                


                 if (secim_tipi == "şoför")
                {

                    int index1 = gridView1.FocusedRowHandle;
                    secilen_kod = Convert.ToString(gridView1.GetRowCellValue(index1, "KOD").ToString());
                    secilen_ad = Convert.ToString(gridView1.GetRowCellValue(index1, "ADI").ToString());
                     secilen_plaka= Convert.ToString(gridView1.GetRowCellValue(index1, "PLAKA").ToString());
                    secilen_tel = Convert.ToString(gridView1.GetRowCellValue(index1, "TEL").ToString());
                    Close();
                }
                 if (secim_tipi == "barkod")
                 {

                     int index1 = gridView1.FocusedRowHandle;
                     secilen_kod = Convert.ToString(gridView1.GetRowCellValue(index1, "BARKOD").ToString());
                     
                     Close();
                 }
              
            }
            catch { }
         }

        private void gridView1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData == Keys.Enter)
            {
                try
                {



                    if (secim_tipi == "")
                    {

                        int index1 = gridView1.FocusedRowHandle;
                        secilen_kod = Convert.ToString(gridView1.GetRowCellValue(index1, "KOD").ToString());
                        secilen_ad = Convert.ToString(gridView1.GetRowCellValue(index1, "ADI").ToString());
                      
                        Close();
                    }



                    if (secim_tipi == "şoför")
                    {

                        int index1 = gridView1.FocusedRowHandle;
                        secilen_kod = Convert.ToString(gridView1.GetRowCellValue(index1, "KOD").ToString());
                        secilen_ad = Convert.ToString(gridView1.GetRowCellValue(index1, "ADI").ToString());
                        secilen_plaka = Convert.ToString(gridView1.GetRowCellValue(index1, "PLAKA").ToString());
                        secilen_tel = Convert.ToString(gridView1.GetRowCellValue(index1, "TEL").ToString());
                        Close();
                    }
                    if (secim_tipi == "barkod")
                    {

                        int index1 = gridView1.FocusedRowHandle;
                        secilen_kod = Convert.ToString(gridView1.GetRowCellValue(index1, "BARKOD").ToString());

                        Close();
                    }
                }
                catch { }
                if (e.KeyData == Keys.Escape)
                { Close(); }
            }
        }
    }
}